#!/bin/csh -f
set echo_style=both
# xyz2para: maps fully relaxed xyz file onto given parameter basis
# USAGE: xyz2para config_para_name XYZ_FNAME
 
# PARAMETERS:
# input_type is either plain tiling (1) or config_para (2)

set USAGE="USAGE: xyz2para config_name xyz_rel_name"

if !($# == 2) then 
    echo $USAGE
    exit
endif

if !( -r $2 ) then 
    echo XYZ_REL FILE $2 does not exist.
    echo $USAGE
    exit
endif
if !( -r $1 ) then 
    echo CONFIG_PARA FILE $1 does not exist.
    echo $USAGE
    exit
endif

#input type is set automatically:
set INP_TYPE=`awk 'BEGIN{mode=0}FNR<=4{m[FNR]=NF}FNR==3{nn=$1}(FNR>4&&m[2]==5&&m[3]==5&&m[4]==6){mode=3}(FNR>4&&m[1]==3&&m[2]==5&&m[3]==5){mode=4}(FNR==4+nn&&mode==0){mode=1}END{print mode}' $1`
#set INP_TYPE="`awk 'FNR==3{if(NF==3){print 2}else{print 1}}' $1`"

echo $INP_TYPE\\n$1\\n$2 | $DECAHOME/bin/xyz2para_
## 





